export function getPhone(param) {

	return uni.$u.http.post('users/wxMiniPhone', param);

}

export function getAuthInfo() {

	//return uni.$u.http.get('users/auth/info');

	return new Promise(function(resolve, reject) {
		var authInfo = uni.getStorageSync("authInfo")
		// 要做的事情...
		if (authInfo) {
			resolve(authInfo)
		} else {
			uni.$u.http.get('users/auth/info').then(res => {
				uni.setStorageSync("authInfo", res)
				resolve(res)
			}).catch(function(err) {
				reject(err)
			})
		}
	});

}
export function getAuthByInfo(userId = 0) {

	//return uni.$u.http.get('users/auth/info');

	return new Promise(function(resolve, reject) {
		var authInfo = uni.getStorageSync("getAuthByInfo" + userId)
		// 要做的事情...
		if (authInfo) {
			resolve(authInfo)
		} else {
			uni.$u.http.get('users/findByOnId?userId=' + userId).then(res => {
				uni.setStorageSync("getAuthByInfo" + userId, res)
				resolve(res)
			}).catch(function(err) {
				reject(err)
			})
		}
	});

}
export function editAuthInfo(param) {



	return new Promise(function(resolve, reject) {

		// 要做的事情...
		uni.$u.http.post('users/auth/edit', param).then(res => {
			uni.setStorageSync("authInfo", res)
			resolve(res)
		}).catch(function(err) {
			reject(err)
		})
	});
}



export function getFindByAddressList() {

	//return uni.$u.http.get('users/auth/info');

	return uni.$u.http.get('users/address/findByList')

}
export function editAddress(param) {

	return uni.$u.http.post('users/address/edit', param)
}
export function findByIdAddress(id) {
	return uni.$u.http.get('users/address/findById?id=' + id)
}
export function findByDelete(id) {
	return uni.$u.http.post('users/address/byDelete?id=' + id)
}


export function getFindByAgentList(param) {

	//return uni.$u.http.get('users/auth/info');
	var a = uni.$u.queryParams(param)
	return uni.$u.http.get('users/findByAgentMiniList' + a)

}

//findMyBrithList
export function findMyBrithList() {

	//return uni.$u.http.get('users/auth/info');

	return uni.$u.http.get('users/findMyBrithList')

}

export function myEdit(param) {



	//console.log(param, accountInfo, appBaseInfo,accountInfo)
	var url = 'users/myEdit';

	return uni.$u.http.post(url, param);


}
export function regesterMini(param) {



	//console.log(param, accountInfo, appBaseInfo,accountInfo)
	var url = 'users/regesterMini';

	return uni.$u.http.post(url, param);


}


export function serachByPhone(phone = "") {
	return uni.$u.http.get("users/serachByPhone?phone=" + phone)
}
//
export function findByTreeList(param) {
		var a = uni.$u.queryParams(param)
	return uni.$u.http.get("users/findMyTreeList"+a)
}
export function findByPageMiniList(page = 0, phone = "",agentId=0) {

	return uni.$u.http.get('users/findByPageMiniList?pageSize=20&page=' + page + '&phone=' + phone+"&agentId="+agentId)
}
export function findByPageBackAgentMiniList(page = 0, phone = "") {

	return uni.$u.http.get('users/findByPageBackAgentMiniList?pageSize=20&page=' + page + '&phone=' + phone)
}

export function getFindById(userId = 0) {

	//return uni.$u.http.get('users/auth/info');

	return uni.$u.http.get('users/findById?userId=' + userId)

}

export function findByOutId(userId = 0) {

	//return uni.$u.http.get('users/auth/info');

	return uni.$u.http.get('users/findByOutId?userId=' + userId)

}
//

export function myPasswordEdit(form) {

	//return uni.$u.http.get('users/auth/info');

	return uni.$u.http.post('users/myPasswordEdit',form)

}
export function changeAvatar(avatar = "") {



	//console.log(param, accountInfo, appBaseInfo,accountInfo)
	var url = 'upload/avatar';

	return uni.$u.http.upload(url, {
		name: "file",
		filePath: avatar,
		fileType: "image"
	});


}
//nickEdit
export function nickEdit(form) {

	//return uni.$u.http.get('users/auth/info');

	return uni.$u.http.post('users/nickEdit',form)

}